<% scope[:pipeline_instances].each do |pipeline_instance| %>
    <div>
        <span class="stages stages_with_pipeline_counter pim_dropdown" style="width: 98%;">
            <div class="stage_bar_pipeline_counter" style="width: 3%;">
                <%= pipeline_instance.getCounter() -%>
            </div>
            <% pipeline_instance.getStageHistory().each do |sim_for_pipeline|
                scope[:html_options] = stage_bar_options(sim_for_pipeline) %>
                <div style='width: <%= stage_width_percent(pipeline_instance.numberOfStages(), false, 95) %>' class="stage">
                    <div class="stage_bar_wrapper">
                        <% if placeholder_stage?(sim_for_pipeline) %>
                            <div <%= scope[:html_options] -%>></div>
                        <% elsif pipeline_instance.isBisect() %>
                            <div class="text_in_dropdown disabled_text_in_dropdown">Cannot compare with this instance because it was manually triggered with a non-sequential revision</div>
                        <% else %>
                            <a href="<%= pipeline_compare_href(scope[:pipeline_name], scope[:fixed_pipeline_counter], pipeline_instance.getCounter()) -%>" <%= scope[:html_options] -%> id="<%= "stage_detail_#{scope[:suffix]}_#{pipeline_instance.getCounter()}" %>"></a>
                        <% end %>
                    </div>
                </div>
            <% end %>
        </span>
    </div>
<% end %>
<% if scope[:pipeline_instances].getPagination().getCurrentPage() == scope[:pipeline_instances].getPagination().getLastPage() %>
    <div class="text_in_dropdown">
        <a href="<%= pipeline_compare_href(scope[:pipeline_name], scope[:fixed_pipeline_counter], 0) -%>" id="<%= "stage_detail_#{scope[:suffix]}_0" %>">
            Since pipeline was created
        </a>
    </div>
<% end %>

<% if scope[:pipeline_instances].getPagination().getTotalPages() > 0 %>
    <div class="pagination">
        <% scope[:pipeline_instances].getPagination().getPages().each do |pages| %>
            <% if pages.isDots() %>
                <span>...</span>
            <% else %>
                <% unless pages.isCurrent() %>
                    <a href="javascript:void(0);" id="<%= scope[:dom_id] = "pipeline_history_#{scope[:suffix]}_#{pages.getLabel()}" %>"><%= pages.getLabel() %></a>
                    <script type='text/javascript'>
                        ComparePipelines.bindPagesLink('<%= scope[:dom_id] %>',
                                "<%= compare_pipelines_page_path(:page => page_num=pages.getNumber(), :selected => scope[:selected_pipeline_counter], :fixed_pipeline_counter => scope[:fixed_pipeline_counter], :suffix => scope[:suffix]) -%>",
                                <%= page_num%>);
                    </script>
                <% else %>
                    <span class="current_page" id="<%= scope[:dom_id] = "pipeline_history_#{scope[:suffix]}_#{pages.getLabel()}" %>"><%= pages.getLabel() %></span>
                <% end %>
            <% end %>
        <% end %>
    </div>
<% end %>
